package save;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.media.jai.PlanarImage;

import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageEncoder;
import com.sun.media.jai.codec.PNMEncodeParam;

public class SavePNM extends Save {

public boolean makeSave(PlanarImage src, String filename)
{
		boolean flag=true;			
		//gravando	
		try {
			OutputStream os = new FileOutputStream(filename);
			PNMEncodeParam param = new PNMEncodeParam();
			ImageEncoder enc = ImageCodec.createImageEncoder("PNM", os, param);
			enc.encode(src);
			os.close();

		} catch (IOException e) {
			e.printStackTrace();
			System.out.println("Error to save in PNM format");
			System.exit(0);
			flag=false;	
		}
		return flag;
}

}
